######################################################
### Appendix Figure C1, Robustness Checks ############
######################################################
#Upper left plot
fig_A4a1 <- lm(supp_dem2 ~ unauthorised, data = dat)
fig_A4a2 <- lm(supp_dem2 ~ unauthorised + age + gender + education +putin_voter + unauth_acc + legal_concerns, data = dat)
fig_A4a3 <- lm(supp_dem ~  unauthorised + age + gender +education, data = dat)
fig_A4a4 <- lm(supp_dem3 ~ unauthorised + age + gender +education, data = dat)
fig_A4a5 <- lm(supp_dem4 ~ unauthorised + age + gender +education, data = dat)

rob_plot1<-plot_summs(fig_A4a1, fig_A4a2, fig_A4a3, fig_A4a4, fig_A4a5,
                      coefs = c("Unauthorized" ="unauthorised"),
                      scale = TRUE, color.class = "Greys", robust = FALSE,
                      model.names = c("No Controls", "Full controls", "Recoded DV", "BinaryDV", "Binary Recoded"))
rob_plot1

#Top left plot
dat$treatfactor<-as.factor(dat$supp_dem2)
class(dat$treatfactor)
dat$treatfactor1<-as.factor(dat$supp_dem)
class(dat$treatfactor1)

fig_A4b1 <- polr(treatfactor ~ unauthorised, data= dat, Hess=TRUE)
fig_A4b2 <- polr(treatfactor ~ unauthorised + age + gender + education +putin_voter + unauth_acc + legal_concerns, data= dat, Hess=TRUE)
fig_A4b3 <- polr(treatfactor1 ~ unauthorised + age + gender + education, data= dat, Hess=TRUE)
fig_A4b4 <- glm(supp_dem3 ~ unauthorised + age + gender + education, data= dat, family = "binomial")
fig_A4b5 <- glm(supp_dem4 ~ unauthorised + age + gender + education, data= dat, family = "binomial")

rob_plot2<-plot_summs(fig_A4b1, fig_A4b2, fig_A4b3, fig_A4b4, fig_A4b5,
                      coefs = c("Unauthorized" ="unauthorised",
                                "Unauthorized" ="unauthorisedunauthorised"),
                      scale = TRUE, color.class = "Greys", robust = FALSE,
                      model.names = c("No Controls", "Full controls", "Recoded DV", "BinaryDV", "Binary Recoded"))
rob_plot2

#Bottom left plot
fig_A4c1 <- lm(part_dummy2 ~ unauthorised, data = dat)
fig_A4c2 <- lm(part_dummy2 ~ unauthorised + age + gender + education +putin_voter + unauth_acc + legal_concerns, data = dat)
fig_A4c3 <- lm(part_dummy ~ unauthorised + age + gender +education, data = dat)
fig_A4c4 <- lm(part_dummy2 ~ unauthorised + age + gender +education +supp_dem2, data = dat)

rob_plot3<-plot_summs(fig_A4c1, fig_A4c2, fig_A4c3, fig_A4c4,
                      coefs = c("Unauthorized" ="unauthorised"),
                      scale = TRUE, color.class = "Greys", robust = FALSE,
                      model.names = c("No Controls", "Full controls", "Recoded DV", "+ Protester approval"))
rob_plot3

#Bottom right plot
fig_A4d1 <- glm(part_dummy2 ~ unauthorised, data= dat, family = "binomial")
fig_A4d2 <- glm(part_dummy2 ~ unauthorised + age + gender + education +putin_voter + unauth_acc + legal_concerns, data= dat, family = "binomial")
fig_A4d3 <- glm(part_dummy ~ unauthorised +age +gender +education, data= dat, family = "binomial")
fig_A4d4 <- glm(part_dummy2 ~ unauthorised + age + gender + education +supp_dem2, data= dat, family = "binomial")

rob_plot4<-plot_summs(fig_A4d1, fig_A4d2, fig_A4d3, fig_A4d4,
                      coefs = c("Unauthorized" ="unauthorised",
                                "Unauthorized" ="unauthorisedunauthorised"),
                      scale = TRUE, color.class = "Greys", robust = FALSE,
                      model.names = c("No Controls", "Full controls", "Recoded DV", "+Protester Approval"))
rob_plot4

apatheme= theme_apa(
  legend.font.size = 8,
  x.font.size = 8,
  y.font.size = 10,
  facet.title.size = 8,
  remove.y.gridlines = TRUE,
  remove.x.gridlines = TRUE
)

rob<-rob_plot1  + apatheme + labs(x = "Protester Approval, OLS Models", y = "")  
rob1<-rob_plot2  + apatheme + labs(x = "Protester Approval, OLogit and Logit Models", y = "")  
rob2<-rob_plot3  + apatheme + labs(x = "Protest Support, OLS Models", y = "")  
rob3<-rob_plot4  + apatheme + labs(x = "Protest Support, Logit Models", y = "")  

ggsave(height=5,
       width=8,
       "Figures/robust_figure1_revised.png",
       arrangeGrob(rob, rob1, rob2, rob3, ncol=2)
)
